#include "../Library/GMPrintText.h"
#include "../Library/GameMessageFactory.h"
#include <iostream>

const char* GMPrintText::m_NAME = "PrintText"; 
static bool registered = TheGameMessageFactory::Instance()->AddObject(GMPrintText::m_NAME, GMPrintText::Create);

GMPrintText::GMPrintText()
{
	m_Msg = "";
}

GMPrintText::GMPrintText(const char* text)
{
	m_Msg = text;
}

GMPrintText::~GMPrintText()
{}

void GMPrintText::Execute()
{
	std::cout<<m_Msg;
}

bool GMPrintText::ReadFromSocketM(SockMessage* sm)
{
	std::cout<<"Reading message: "<<m_NAME<<"\n";
	sm->ReadString(&m_Msg);
	return true;
}
bool GMPrintText::WriteToSocketM(SockMessage* sm)
{
	std::cout<< "Writing message: "<<m_NAME <<"\n";
	sm->WriteString(m_Msg);
	return true;
}

GameMessage* GMPrintText::Create()
{
	return new GMPrintText;
}